<?php
/***************************************************
 * FileUpload Component
 *
 * Manages uploaded files to be saved to the file system.
 *
 * @copyright    Copyright 2009, Webtechnick
 * @link         http://www.webtechnick.com
 * @author       Nick Baker
 * @version      1.4
 * @license      MIT
 */
class ImgComponent extends Component {

    public function initialize(Controller $controller) {
        // $this->data = $controller->data;
        // $this->params = $controller->params;
    }

    public function beforeRender(Controller $controller) {
    }


    public function shutdown(Controller $controller) {
    }

    /***************************************************
     * Main execution method.  Handles file upload automatically upon detection and verification.
     *
     * @param object $controller A reference to the instantiating controller object
     * @return void
     * @access public
     */
    public function startup(Controller $controller) {

    // if ($this->_checkFile() && $this->checkType()) {
    // $this->_processFile();
    // }
    }

  function uploaderFilename($name, $field, $data) {
    return md5($name);
    }



    /*************************************************
     * showErrors itterates through the errors array
     * and returns a concatinated string of errors sepearated by
     * the $sep
     *
     * @param string $sep A seperated defaults to <br />
     * @return string
     * @access public
     */
    public function showErrors($sep = "<br />") {
        $retval = "";
        foreach ($this->errors as $error) {
            $retval .= "$error $sep";
        }
        return $retval;
    }


    /***************************************************
     * Adds error messages to the component
     *
     * @param string $text String of error message to save
     * @return void
     * @access protected
     */
    function error($text) {
        $message = __($text, true);
        $this->errors[] = $message;
        trigger_error($message, E_USER_WARNING);
    }

}
?>